package Class;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;

public class DateTest {
    public static void main(String[] args) {
        LocalDate d = LocalDate.now();
        System.out.println(d.getYear()+"  "+d.getMonthValue()+"  "+d.getDayOfMonth());

        LocalTime t = LocalTime.now();
        System.out.println(t.getHour()+"  "+t.getMinute()+"  "+t.getSecond());

        LocalDateTime dateTime = LocalDateTime.now();
        System.out.println(dateTime);


        LocalDate date = LocalDate.now();
        LocalDate x = date.plusDays(100);
        System.out.println(x);

        //当前时间
        LocalDate nowDate = LocalDate.now();
        //过年时间
        LocalDate yearDate = LocalDate.of(2022,1,31);
        //计算两个时间的时间差
        long days = ChronoUnit.DAYS.between(nowDate,yearDate);
        System.out.println(days);

        LocalDate n = LocalDate.now();
        System.out.println(n);
        String str = DateTimeFormatter.ofPattern("yyyy年MM月dd日").format(n);
        System.out.println(str);

        LocalDate ss = LocalDate.parse("1998-03-20");
        System.out.println(ss);



    }
}
